package com.zjp.service;

import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;

@Service
@EnableScheduling
public class OrderService {


    /**
     * ProducerOrConsumerPropertyCondition 这个条件成立时才会加载
     *
     * @see RocketMQAutoConfiguration.ProducerOrConsumerPropertyCondition
     * @see DefaultMQProducer
     * @see DefaultLitePullConsumer
     * 最后对应 @ConditionalOnProperty(prefix = "rocketmq", value = {"name-server", "consumer.group", "consumer.topic"})
     * 这三个属性是否存在
     */
    /*@Autowired
    RocketMQTemplate rocketMQTemplate;
    @Autowired
    RocketMQConfig rocketMQConfig;
    @Value("${common.topic}")
    String topic;*/

    //@Scheduled(fixedRate = 5000) // 间隔5秒执行
    /*public void send() {

        String now = DateUtil.now();
        Message<String> message = MessageBuilder.withPayload("发送时间" + now)
                .setHeader(RocketMQHeaders.KEYS, topic)
                .build();
        SendResult result = rocketMQTemplate.syncSend(topic, message, 5000,2);
        if (SendStatus.SEND_OK == result.getSendStatus()) {
            System.out.println(DateUtil.now() + "-- 发送成功");
        }

    }*/

}
